

Public Class DAOHoaDOn
    Public Shared Function HoaDOn_Load() As DataTable
        Return DataProvider.LoadTable("Select * from HoaDOn")
    End Function
    'load ban an
    Public Shared Sub HoaDOn_Insert(ByVal n As DTOHoaDon)
        Dim sql As String = String.Format("insert into HOADON(NgayXuat,MaKH,TenKH,MaBan,TenBan,TongTien,MaNV,tinhtrang) values('{0}','{1}',N'{2}','{3}','{4}','{5}','{6}',{7})", _
                                        n.NgayXuat, n.MaKH, n.TenKH, n.MaBan, n.TenBan, n.TongTien, n.MaNV, n.Tinhtrang)
        DataProvider.ExecuteNonQuery(sql)
    End Sub

    Public Shared Sub HoaDOn_Update(ByVal n As DTOHoaDon)
        Dim sql As String = String.Format("update HOADON set NgayXuat = '{0}',MaKH= '{1}',TenKH= N'{2}',MaBan= '{3}',TenBan= '{4}',TongTien= '{5}',MaNV= '{6}',Tinhtrang = {8} where MaHD = {7}", _
                                           n.NgayXuat, n.MaKH, n.TenKH, n.MaBan, n.TenBan, n.TongTien, n.MaNV, n.MaHD,n.Tinhtrang)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
    Public Shared Sub HoaDOn_Delete(ByVal n As DTOHoaDon)
        If AgreeForm.deleteCaution = False Then
            Return
        End If
        Dim sql As String = String.Format("delete HoaDOn where HoaDon = '{0}'", n.MaHD)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
End Class